package mappedClass;

// Generated 3 juil. 2014 12:40:01 by Hibernate Tools 3.4.0.CR1

import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

/**
 * Task generated by hbm2java
 */
@Entity
@Table(name = "task", catalog = "test", uniqueConstraints = @UniqueConstraint(columnNames = "description"))
@Inheritance(strategy=InheritanceType.JOINED)
public class Task implements java.io.Serializable {

	private Integer id;
	private TypeTask typeTask;
	private String description;
	private Set<Team> teams = new HashSet<Team>(0);
	private Set<TaskExpense> taskexpenses = new HashSet<TaskExpense>(0);
	private Set<ProjectPV> projectpvs = new HashSet<ProjectPV>(0);
	private Set<ProjectAC> projectacs = new HashSet<ProjectAC>(0);
	private Set<ProjectEV> projectevs = new HashSet<ProjectEV>(0);
	private Set<UserTask> usertasks = new HashSet<UserTask>(0);

	public Task() {
	}

	public Task(TypeTask typeTask, String description) {
		this.typeTask = typeTask;
		this.description = description;
	}

	public Task(TypeTask typeTask, String description, Set<Team> teams,
			Set<TaskExpense> taskexpenses,
			Set<ProjectPV> projectpvs, Set<ProjectAC> projectacs,
			Set<ProjectEV> projectevs, Set<UserTask> usertasks) {
		this.typeTask = typeTask;
		this.description = description;
		this.teams = teams;
		this.taskexpenses = taskexpenses;
		this.projectpvs = projectpvs;
		this.projectacs = projectacs;
		this.projectevs = projectevs;
		this.usertasks = usertasks;
	}

	@Id
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "id", unique = true, nullable = false)
	public Integer getId() {
		return this.id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "typeTaskId", nullable = false)
	public TypeTask getTypetask() {
		return this.typeTask;
	}

	public void setTypetask(TypeTask typeTask) {
		this.typeTask = typeTask;
	}

	@Column(name = "description", unique = true, nullable = false, length = 200)
	public String getDescription() {
		return this.description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	@ManyToMany(fetch = FetchType.LAZY)
	@JoinTable(name = "teamtask", catalog = "test", joinColumns = { @JoinColumn(name = "taskId", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "teamId", nullable = false, updatable = false) })
	public Set<Team> getTeams() {
		return this.teams;
	}

	public void setTeams(Set<Team> teams) {
		this.teams = teams;
	}

	@OneToMany(fetch = FetchType.LAZY)
	public Set<TaskExpense> getTaskexpenses() {
		return this.taskexpenses;
	}

	public void setTaskexpenses(Set<TaskExpense> taskexpenses) {
		this.taskexpenses = taskexpenses;
	}

	@OneToMany(fetch = FetchType.LAZY)
	public Set<ProjectPV> getProjectpvs() {
		return this.projectpvs;
	}

	public void setProjectpvs(Set<ProjectPV> projectpvs) {
		this.projectpvs = projectpvs;
	}

	@OneToMany(fetch = FetchType.LAZY)
	public Set<ProjectAC> getProjectacs() {
		return this.projectacs;
	}

	public void setProjectacs(Set<ProjectAC> projectacs) {
		this.projectacs = projectacs;
	}

	@OneToMany(fetch = FetchType.LAZY)
	public Set<ProjectEV> getProjectevs() {
		return this.projectevs;
	}

	public void setProjectevs(Set<ProjectEV> projectevs) {
		this.projectevs = projectevs;
	}

	@OneToMany(fetch = FetchType.LAZY)
	public Set<UserTask> getUsertasks() {
		return this.usertasks;
	}

	public void setUsertasks(Set<UserTask> usertasks) {
		this.usertasks = usertasks;
	}

	@Override
	public String toString() {
		return "Task [id=" + id + ", typeTask=" + typeTask + ", description="
				+ description + ", teams=" + teams + ", taskexpenses=" + taskexpenses
				+ ", projectpvs=" + projectpvs + ", projectacs=" + projectacs
				+ ", projectevs=" + projectevs + ", usertasks=" + usertasks;
	}

}
